package testClasses.misc;

import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.util.BufferUtils;

public class FSquareMesh {
	
	public Mesh buildMesh() {
		
		Mesh mesh = new Mesh();
		
		Vector3f [] vertices = new Vector3f[4];
		vertices[0] = new Vector3f(0,0,0);
		vertices[1] = new Vector3f(3,0,0);
		vertices[2] = new Vector3f(0,3,0);
		vertices[3] = new Vector3f(3,3,0);
		
		Vector2f[] texCoord = new Vector2f[4];
		texCoord[0] = new Vector2f(0,0);
		texCoord[1] = new Vector2f(1,0);
		texCoord[2] = new Vector2f(0,1);
		texCoord[3] = new Vector2f(1,1);
		
		int [] indexes = {2,0,1, 1,3,2};
		
		mesh.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vertices));
		mesh.setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(texCoord));
		mesh.setBuffer(Type.Index,    1, BufferUtils.createIntBuffer(indexes));
		mesh.updateBound();
		mesh.setStatic();
		
		
		return mesh;		
	}

}
